﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FAST
{
    public class UpdateDetection
    {
        private FileSystem fs;
        private OriginalState leftOS,rightOS;
        private Session sess;
        private string leftOSPath,rightOSPath;

        public UpdateDetection()
        {
            fs = new FileSystem();

            sess = new Session();            
            SessionItem sessItem = sess.getLastLoadedSession();
            if (sessItem != null)
            {
                leftOSPath = sessItem.getNewOriginalStatePathLeft();
                rightOSPath = sessItem.getNewOriginalStatePathRight();
            }
            else
            {
                leftOSPath = "";
                rightOSPath = "";
            }
            leftOS = new OriginalState(leftOSPath); //use default file to write path
            rightOS = new OriginalState(rightOSPath); //use default file to write path
            fs.setOSFileDetails(leftOS.getOriginalState(), rightOS.getOriginalState());
        }

        public void removeOS()
        {
            fs.setOSFileDetails(null,null);
        }

        public List<FilesHandler> getLeftFolderList()
        {
            return fs.getLeftFileDetails();
        }

        public List<FilesHandler> getRightFolderList()
        {
            return fs.getRightFileDetails();
        }

        //recursively generate left folder tree structure
        public void processLeftFolder(string src)
        {
            fs.generateLeftFolderTree(src, src);
        }

        //recursively generate right folder tree structure and compare each file in right with all files in left
        public void processRightFolder(string des)
        {
            fs.generateRightFolderTree(des, des);
        }

    }
}
